class Solution:
    def fib(self, n: int) -> int:
        def dp(mean,n):
            if n == 0 or n == 1:
                return n
            if mean[n] != 0:
                return mean[n]
            mean[n] = dp(mean,(n-1)) + dp(mean,(n-2))
            return mean[n]
        
        mean = [0] * (n + 1)
        return dp(mean,n)
    
    def fib2(self, n: int) -> int:
        if n == 0:
            return 0
        dp = [0] * (n+1)
        dp[0] = 0
        dp[1] = 1
        for i in range(2,n+1):
            dp[i] = dp[i - 1] + dp[i - 2]
        return dp[n]